Skip to content

Add filtering by code to vouchers in UI, fix e2e#6409

Open
witoszekdev wants to merge 9 commits intomainfrom
fix-vouchers-search-e2e
Open

Add filtering by code to vouchers in UI, fix e2e#6409
witoszekdev wants to merge 9 commits intomainfrom
fix-vouchers-search-e2e

Conversation

@witoszekdev
Copy link
Member

@witoszekdev witoszekdev commented Mar 10, 2026

Added option to filter gift cards by code in "Filter" menu, updated e2e test to use that filtering instead of search which takes a moment to index, which sometimes failed in test environment.

@witoszekdev witoszekdev requested a review from a team as a code owner March 10, 2026 16:21
@witoszekdev witoszekdev requested review from Copilot and lkostrowski and removed request for Copilot March 10, 2026 16:21
@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2026

🦋 Changeset detected

Latest commit: f99a45e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@witoszekdev witoszekdev added test deployment Deploy Pull Request to *.saleor.rocks environment run pw-e2e Run e2e (basic suite from PR automation) labels Mar 10, 2026
@github-actions github-actions bot temporarily deployed to pr-6409 March 10, 2026 16:30 Destroyed
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 36.36364% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.19%. Comparing base (659142b) to head (f99a45e).

Files with missing lines Patch % Lines
...initialState/giftCards/useInitialGiftCardsState.ts 0.00% 3 Missing ⚠️
...ents/ConditionalFilter/API/initialState/helpers.ts 0.00% 2 Missing ⚠️
...ilter/API/providers/GiftCardsFilterAPIProvider.tsx 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6409      +/-   ##
==========================================
- Coverage   43.19%   43.19%   -0.01%     
==========================================
  Files        2527     2527              
  Lines       44074    44081       +7     
  Branches    10440    10405      -35     
==========================================
+ Hits        19037    19040       +3     
- Misses      23715    23718       +3     
- Partials     1322     1323       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@witoszekdev witoszekdev marked this pull request as draft March 10, 2026 16:41
Copilot AI review requested due to automatic review settings March 11, 2026 12:19
@witoszekdev witoszekdev added run pw-e2e Run e2e (basic suite from PR automation) test deployment Deploy Pull Request to *.saleor.rocks environment and removed run pw-e2e Run e2e (basic suite from PR automation) test deployment Deploy Pull Request to *.saleor.rocks environment labels Mar 11, 2026
@witoszekdev witoszekdev added test deployment Deploy Pull Request to *.saleor.rocks environment run pw-e2e Run e2e (basic suite from PR automation) and removed run pw-e2e Run e2e (basic suite from PR automation) test deployment Deploy Pull Request to *.saleor.rocks environment labels Mar 11, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “Code” filter to the Gift Cards conditional filter UI and updates the Playwright E2E test to use that filter instead of search (to avoid eventual indexing delays).

Changes:

  • Add Gift Cards “Code” filter operand + condition configuration.
  • Extend URL token parsing / initial-state plumbing to carry code through the conditional filter system.
  • Update Gift Cards E2E to apply a “Code” text filter via the filters UI.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/components/ConditionalFilter/constants.ts Adds the Gift Cards “Code” left operand and a new static condition entry.
src/components/ConditionalFilter/ValueProvider/UrlToken.ts Marks code as a loadable static token for gift cards.
src/components/ConditionalFilter/ValueProvider/TokenArray/fetchingParams.ts Adds code to gift-card fetching params + empty defaults.
src/components/ConditionalFilter/ValueProvider/TokenArray/fetchingParams.test.ts Updates expectations to include code in params.
src/components/ConditionalFilter/API/providers/GiftCardsFilterAPIProvider.tsx Adds a handler branch intended for the new code filter.
src/components/ConditionalFilter/API/initialState/helpers.ts Threads code into initial gift-card state creation.
src/components/ConditionalFilter/API/initialState/giftCards/useInitialGiftCardsState.ts Passes code into initial state and response.
src/components/ConditionalFilter/API/initialState/giftCards/InitialGiftCardsState.ts Adds code storage/lookup for URL token rehydration.
playwright/tests/giftCards.spec.ts Switches E2E from search to “Code” filter flow.
playwright/pages/pageElements/filtersPage.ts Adds helper to pick a text filter in the filters UI.
playwright/pages/giftCardsPage.ts Wires FiltersPage into the GiftCards page object.

isPreorder: [{ type: "select", label: "is", value: "input-1" }],
isGiftCardUsed: [{ type: "select", label: "is", value: "input-1" }],
isGiftCardBought: [{ type: "select", label: "is", value: "input-1" }],
giftCardCode: [{ type: "text", label: "is", value: "input-1" }],
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STATIC_CONDITIONS key is giftCardCode, but the gift card left operand uses slug: "code"/value: "code". URL tokens and FilterElement.rowType() use value.value (the slug), so this mismatch prevents the condition from being rehydrated from URL and can make the filter behave as "unknown". Align the static condition key with the URL/slug (e.g. use code as the STATIC_CONDITIONS key) so ConditionOptions.isStaticName(token.name) works for this filter.

Suggested change
giftCardCode: [{ type: "text", label: "is", value: "input-1" }],
code: [{ type: "text", label: "is", value: "input-1" }],

Copilot uses AI. Check for mistakes.
Comment on lines 47 to 51
case "usedBy":
return this.usedBy;
case "code":
return this.code;
default:
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InitialGiftCardsStateResponse now supports resolving code tokens via getEntryByName, but the existing unit tests for filterByUrlToken() don’t cover this new case (they cover currency/tags/products/usedBy/isActive). Add a test for the code field to ensure URL rehydration works and to catch regressions when adjusting the code/giftCardCode naming.

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot temporarily deployed to pr-6409 March 11, 2026 12:26 Destroyed
@witoszekdev witoszekdev added run pw-e2e Run e2e (basic suite from PR automation) and removed run pw-e2e Run e2e (basic suite from PR automation) test deployment Deploy Pull Request to *.saleor.rocks environment labels Mar 11, 2026
Copilot AI review requested due to automatic review settings March 11, 2026 14:01
@witoszekdev witoszekdev marked this pull request as ready for review March 11, 2026 14:02
@witoszekdev witoszekdev added run pw-e2e Run e2e (basic suite from PR automation) and removed run pw-e2e Run e2e (basic suite from PR automation) labels Mar 11, 2026
@github-actions github-actions bot temporarily deployed to pr-6409 March 11, 2026 14:10 Destroyed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

"saleor-dashboard": patch
---

Gift cards filters now have option to filder by gift card code explicitly. Previously this was available only in search box, which uses `search` query, this however might not be available immediately after creating a gift card, due to indexing running in the background.
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in changeset text: "filder" should be "filter".

Suggested change
Gift cards filters now have option to filder by gift card code explicitly. Previously this was available only in search box, which uses `search` query, this however might not be available immediately after creating a gift card, due to indexing running in the background.
Gift cards filters now have option to filter by gift card code explicitly. Previously this was available only in search box, which uses `search` query, this however might not be available immediately after creating a gift card, due to indexing running in the background.

Copilot uses AI. Check for mistakes.
Comment on lines +723 to +728
value: "code",
label: "Code",
type: "code",
slug: "code",
maxOccurrences: 1,
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New "Code" gift card filter is added, but there’s no unit test asserting how it maps into createGiftCardQueryVariables output (e.g. that a text "is" condition produces GiftCardFilterInput.code). Adding a focused test case in src/components/ConditionalFilter/queryVariables.test.ts would prevent regressions in this new filtering capability.

Copilot uses AI. Check for mistakes.

readonly setGiftCardsBalanceDialog: SetGiftCardsBalanceDialog;

readonly filtersPage!: FiltersPage;
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filtersPage is always initialized in the constructor, so the definite assignment assertion (!) is unnecessary and can mask real initialization issues. Declare it as readonly filtersPage: FiltersPage; instead.

Suggested change
readonly filtersPage!: FiltersPage;
readonly filtersPage: FiltersPage;

Copilot uses AI. Check for mistakes.
@witoszekdev witoszekdev added run pw-e2e Run e2e (basic suite from PR automation) and removed run pw-e2e Run e2e (basic suite from PR automation) labels Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run pw-e2e Run e2e (basic suite from PR automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants